{# 继承母版页basic #}
{% extends 'basic.html' %}
{% load static %}

{# 自定义标题 #}
{% block title %}
    我的博客|登陆
{% endblock %}

{# 导航条选中 #}
{% block nav_home_active %} active {% endblock %}

{# 自定义内容 #}
{% block content %}
     <div class="container">
        <div class="row">
            <div class="col-xs-4 col-xs-offset-4">
            {% if not user.is_authenticated %}
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">登录</h3>
                    </div>
                    <div class="panel-body">
                        <form action="" method="POST">
                            {% csrf_token %}
                            {# 将form表单的字段重新打印出来 避免字段后出现 ： #}
                            {% for field in login_form %}
                                <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                                {{ field }}
                                <p class="text-danger">{{ field.errors.as_text }}</p>
                            {% endfor %}
                            <span class="pull-left text-danger">{{ login_form.non_field_errors.0 }}</span>
                            <div class="clearfix"></div>
                            <a href="{% url 'forgot_password' %}" class="pull-left">忘记密码？</a>
                            <input type="submit" value="登录" class="btn btn-primary pull-right">
                        </form>
                    </div>
                </div>
            </div>
            {% else %}
                    <span>已登录，跳转到首页...</span>
                    <script type="text/javascript">
                        window.location.href = '/';
                    </script>
            {% endif %}
        </div>
    </div>
{% endblock %}